package com.tarena.lbs.article.web.controller;

import com.tarena.lbs.article.web.service.ArticleService;
import com.tarena.lbs.base.protocol.exception.BusinessException;
import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.pojo.content.param.ArticleCategoryParam;
import com.tarena.lbs.pojo.content.param.ArticleContentParam;
import com.tarena.lbs.pojo.content.query.ArticleQuery;
import com.tarena.lbs.pojo.content.vo.ArticleVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ArticleController {
    //前台小程序 后台管理员 查询文章分页列表

    @Autowired
    private ArticleService articleService;

    @GetMapping("/admin/content/article/list")
    public Result<PageResult<ArticleVO>> articlePage(ArticleQuery articleQuery)
        throws BusinessException {
        return new Result<>(articleService.articlePage(articleQuery));
    }
    //新增提交 推文创作
    @PostMapping("/admin/content/article/insert")
    public Result<Void> addArticle(ArticleContentParam param)
        throws BusinessException{
        articleService.addArticle(param);
        return Result.success();
    }
}
